#include "usr_inc.h"

void StartTossCmdDeal(void *argument)
{
    for (;;)
    {
        TossCmdMsg_t cmd;
        float stroke;

        if (xQueueReceive(tossCmdQueueHandle, &cmd, 5) == pdTRUE)
        {
            if (cmd == TOSS_DRAG)
            {
                BSP_FDCAN_SendData(&hfdcan1, 0x201, NULL, FDCAN_DLC_BYTES_0);
            }
            else if (cmd == TOSS_FREE)
            {
                BSP_FDCAN_SendData(&hfdcan1, 0x203, NULL, FDCAN_DLC_BYTES_0);
            }
            else if (cmd == TOSS_ABANDON)
            {
                BSP_FDCAN_SendData(&hfdcan1, 0x204, NULL, FDCAN_DLC_BYTES_0);
            }
        }

        if (xQueueReceive(tossStrokeQueueHandle, &stroke, 5) == pdTRUE)
        {
            uint8_t buf[4];
            memcpy(buf + 0, &stroke, sizeof(float));
            BSP_FDCAN_SendData(&hfdcan1, 0x220, buf, FDCAN_DLC_BYTES_4);
        }
    }
}
